<?php
//队列邮件-接受入队数据
$config = require_once '../../config.php';

$redis = new Redis();
$redis->connect($config['redis_ip'], $config['redis_port']);//ip端口
$redis->auth($config['redis_auth']);//密码
$redis_key = 'email';

$email = isset($_POST['email']) ? $_POST['email'] : NULL;
if(empty($email)){
    echo json_encode(['code'=>false, 'msg'=>'邮箱不能为空'],1);exit;
}

$emailArr = explode(',', $email);
// $time = date('Y-m-d H:s:i');
// $emailArr = [$time];
foreach ($emailArr as $mail){
    $row = json_encode([
        'email'=>$email,
        'status'=>0,//0待发送，1成功，2失败
    ], 1);
    $len = $redis->rPush($redis_key, $row);//返回总数
}
echo json_encode(['code'=>true, 'data'=>['total'=>$len]]);
// $arr = $redis->lrange($redis_key, 0 ,-1);//返回数组
// echo json_encode($arr,1);
exit;

